<template>
	<view>
		<view class="header">
			<view class="text">
				您的评价让我们做的更好!
			</view>
			<uni-rate max="5" size="30" :value="star"></uni-rate>
		</view>
		<textarea v-model="content" placeholder="亲，请对本次服务做出评价" />
		<view class="footer" @click="submit">
			提交评论
		</view>
	</view>
</template>

<script>
	import { comment} from '@/api/user/myOrder/myOrder.js';
	import uniRate from '@/components/uni-rate/uni-rate.vue'
	export default {
		components: {uniRate},
		data() {
			return {
				id:'17',
				star:5,
				content:'',
				type:1,
			};
		},
		onLoad(options) {
			this.type=options.type
			if(options.id){
				this.id=options.id
			}
		},
		methods:{
			async submit(){
				let res=await comment(this.id,this.star,this.content,this.type)
				if(res.msg=='success'){
					uni.showToast({
						title: '评价成功！',
					});
					setTimeout(()=>{
						uni.navigateBack({
						    delta: 1
						});
					},1500)
					
				}else{
					uni.showToast({
						title: res.msg,
						icon:'none'
					});
				}
			}
		}
	}
</script>

<style lang="scss">
	 @import "./css/evaluate.scss";
</style>
